import {Injectable} from '@nestjs/common';
// ORM
import {InjectRepository} from '@nestjs/typeorm';
import {Repository, UpdateResult} from 'typeorm';
import {Auth2ListEntity} from '../entity/auth2.list.entity';
import {Auth2ListDto} from '../dto/auth2.list.dto';

@Injectable()
export class Auth2Service {
    constructor(
        @InjectRepository(Auth2ListEntity)
        private readonly auth2Repository: Repository<Auth2ListEntity>,
    ) {
    }

    async createOneRelation(auth2ListDto: Auth2ListDto): Promise<Auth2ListEntity> {
        return await this.auth2Repository.save(auth2ListDto);
    }

    async getOneByUid(uid: string): Promise<Auth2ListEntity> {
        const qb = this.auth2Repository.createQueryBuilder();
        qb.where({uid})
        return await qb.getOne()
    }
}
